import Vue from 'vue'
import Vuex from 'vuex'

// 声明使用vuex
Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    userId: 0,
    openid: 0,
    paperIdOfRound: 0,
    score: 0,
    grade: 0,
    userGrade: '六年级',
    userSubject: '语文',
    roundSelectNum: 0,
    roundSelectedDate: [],
    myNumsOfRound: 0,
    URL: 'http://172.16.34.89:8080',
    // URL: 'http://127.0.0.1:8080',
    // add papersId,problemsId,problemId
    papersId: [],
    problemsId: [],
    probllemId: [],
    paperId: '',
    numsOfRound: 3,
    // add
    managerGrade: '',
    managerSubject: '',
    paperIdInProblemsList: 0
  },
  getters: {
  },
  mutations: {
    changeGrade (state, newGrade) {
      state.userGrade = newGrade
    },
    changeSubject (state, newSubject) {
      state.userSubject = newSubject
    },
    changeScore (state, newScore) {
      state.userSubject = newScore
    }
  },
  actions: {
    changeGrade (context, newGrade) {
      context.commit('changeGrade', newGrade)
    },
    changeSubject (context, newSubject) {
      context.commit('changeSubject', newSubject)
    },
    changeScore (context, newScore) {
      context.commit('changeScore', newScore)
    }
  }
})
export default store
